<template>
  <div class="user-page" :class="theme">
    <div class="header">
      <h1>我的</h1>
      <div class="theme-switcher">
        <button @click="setTheme('light')" :class="{ active: theme === 'light' }" class="theme-btn light">
          <span class="icon">☀️</span>
          <span>明亮</span>
        </button>
        <button @click="setTheme('dark')" :class="{ active: theme === 'dark' }" class="theme-btn dark">
          <span class="icon">🌙</span>
          <span>暗黑</span>
        </button>
      </div>
    </div>

    <div class="user-profile">
      <div class="avatar-section">
        <div class="avatar">
          <img src="https://via.placeholder.com/150" alt="用户头像">
        </div>
        <div class="user-info">
          <h2>用户名</h2>
          <p>会员等级: 黄金会员</p>
          <p>学习天数: 256天</p>
        </div>
      </div>
      <button class="edit-btn">编辑资料</button>
    </div>

    <div class="stats-container">
      <div class="stat-card">
        <div class="stat-icon">📚</div>
        <div class="stat-content">
          <h3>已学单词</h3>
          <p class="stat-number">1,256</p>
        </div>
      </div>
      <div class="stat-card">
        <div class="stat-icon">⏱️</div>
        <div class="stat-content">
          <h3>学习时长</h3>
          <p class="stat-number">128小时</p>
        </div>
      </div>
      <div class="stat-card">
        <div class="stat-icon">🏆</div>
        <div class="stat-content">
          <h3>成就点数</h3>
          <p class="stat-number">856</p>
        </div>
      </div>
    </div>

    <div class="menu-section">
      <h3 class="section-title">学习记录</h3>
      <div class="menu-grid">
        <div class="menu-item">
          <div class="menu-icon">📅</div>
          <div class="menu-text">学习日历</div>
        </div>
        <div class="menu-item">
          <div class="menu-icon">📊</div>
          <div class="menu-text">学习报告</div>
        </div>
        <div class="menu-item">
          <div class="menu-icon">📝</div>
          <div class="menu-text">错题本</div>
        </div>
        <div class="menu-item">
          <div class="menu-icon">⭐</div>
          <div class="menu-text">收藏单词</div>
        </div>
      </div>
    </div>

    <div class="menu-section">
      <h3 class="section-title">账户设置</h3>
      <div class="menu-grid">
        <div class="menu-item">
          <div class="menu-icon">⚙️</div>
          <div class="menu-text">系统设置</div>
        </div>
        <div class="menu-item">
          <div class="menu-icon">🔒</div>
          <div class="menu-text">隐私与安全</div>
        </div>
        <div class="menu-item">
          <div class="menu-icon">🆘</div>
          <div class="menu-text">帮助中心</div>
        </div>
        <div class="menu-item">
          <div class="menu-icon">📩</div>
          <div class="menu-text">反馈建议</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { inject } from 'vue'

// 主题功能
const theme = inject('theme')

const setTheme = async (newTheme) => {
  theme.value = newTheme
}
</script>

<style scoped>
.user-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  transition: all 0.3s ease;
}

/* 明亮主题 */
.user-page.light {
  background-color: #f5f7fa;
  color: #333;
}

/* 暗黑主题 */
.user-page.dark {
  background-color: #1a1a1a;
  color: #f0f0f0;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.theme-switcher {
  display: flex;
  gap: 10px;
}

.theme-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 15px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.theme-btn.light {
  background-color: #f0f0f0;
  color: #333;
}

.theme-btn.dark {
  background-color: #333;
  color: #f0f0f0;
}

.theme-btn.active {
  transform: scale(1.05);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.user-profile {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card-bg);
  padding: 20px;
  border-radius: 15px;
  margin-bottom: 30px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.light .user-profile {
  --card-bg: #fff;
}

.dark .user-profile {
  --card-bg: #2d2d2d;
}

.avatar-section {
  display: flex;
  align-items: center;
  gap: 20px;
}

.avatar img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
}

.user-info h2 {
  margin: 0;
  font-size: 1.5rem;
}

.user-info p {
  margin: 5px 0 0;
  color: var(--text-secondary);
}

.light .user-info p {
  --text-secondary: #666;
}

.dark .user-info p {
  --text-secondary: #aaa;
}

.edit-btn {
  padding: 8px 20px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.light .edit-btn {
  --primary-color: #4a6bff;
}

.dark .edit-btn {
  --primary-color: #6b8cff;
}

.edit-btn:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

.stats-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.stat-icon {
  font-size: 2rem;
}

.stat-content h3 {
  margin: 0 0 5px;
  font-size: 1rem;
  color: var(--text-secondary);
}

.stat-number {
  margin: 0;
  font-size: 1.5rem;
  font-weight: bold;
}

.menu-section {
  margin-bottom: 30px;
}

.section-title {
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.light .section-title {
  --border-color: #e0e0e0;
}

.dark .section-title {
  --border-color: #444;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
}

.menu-item {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.menu-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
}

.menu-icon {
  font-size: 2rem;
  margin-bottom: 10px;
}

.menu-text {
  font-size: 1rem;
}

@media (max-width: 768px) {
  .stats-container {
    grid-template-columns: 1fr;
  }

  .menu-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
</style>